<?
    session_start();
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
    <head>
        <META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=ISO-8859-1">
        <title>Alterar Problema</title>
        <style type="text/css">@import "rafael.css";</style>
    </head>
    <body>
    <h1>Remover Exemplo</h1>
<?
    if (isset($_POST['cat'])) echo "<p>Categoria: ".$_POST['cat'];
    if (isset($_POST['exemplo'])) echo " - Exemplo nº: ".($_POST['exemplo']+1)."</p>";
    $arq = './user/'.$_SESSION['id_usuario'].'/biblioteca.xml';
    $xml_file = DOMDocument::load( $arq );
    if (isset($_POST['cat']) && isset($_POST['exemplo']))
    {
        $x = $xml_file->getelementsbytagname($_POST['cat']);
        echo $x->length;
        if ($x->length > $_POST['exemplo'])
        {
            $rem = $xml_file->getelementsbytagname($_POST['cat'])->item(0)->parentNode->removeChild($x->item($_POST['exemplo']));
        }
    }
    $xml_file->save($arq);
    if (!$xml_file->getelementsbytagname('problems')->item(0)->hasChildNodes())
        unlink($arq);
?>
<p><a href="remocao.php">Voltar</a></p>
</body>
</html>
